package fi.profecons.csswindows.toolkit;

import fi.profecons.csswindows.Container;

public class MenuItem extends Container {
	
	private String title;
	private String action;
	private Menu subMenu;
	
	public MenuItem(String title){
		super();
		this.title = title;
		addCommand("new MenuItem('" + getId() + "', '" + title + "', null);");
	}
	public MenuItem(String title, String action){
		super();
		this.title = title;
		this.action = action;
		addCommand("new MenuItem('" + getId() + "', '" + title + "', '" + action + "');");
	}
	public String getAction() {
		return action;
	}
	public void setAction(String action) {
		this.action = action;
		addCommand("getElement('" + getId() + "').setAction('" + action + "');");
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
		addCommand("getElement('" + getId() + "').setTitle('" + title + "');");
	}
	public Menu getSubMenu() {
		return subMenu;
	}
	public void setSubMenu(Menu subMenu) {
		getAll().clear();
		getAll().add(subMenu);
		this.subMenu = subMenu;
		addCommand("getElement('" + getId() + "').setSubMenu(getElement('" + subMenu.getId() + "'));");
	}

}
